package com.kczd.jinlan.adapter.normaladapter;

import android.content.Context;
import android.graphics.Bitmap;
import android.widget.ImageView;
import android.widget.TextView;

import com.kczd.jinlan.R;
import com.kczd.jinlan.model.ShoppingCartBean;
import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;

import java.util.List;

/**
 * zhangy
 * Created by Administrator on 2017/5/25.
 */

public class ConfirmOrderAdapter extends BaseCommAdapter<ShoppingCartBean>{


    public PriceNumcallBack priceNumcallBack;


    public void setPriceNumcallBack(PriceNumcallBack priceNumcallBack)
    {
        this.priceNumcallBack=priceNumcallBack;
    }

   public interface PriceNumcallBack{
        void showPrice(String price);
    }

    public ConfirmOrderAdapter(List<ShoppingCartBean> datas) {
        super(datas);
    }
    @Override
    protected void setUI(ViewHolder holder, int position, Context context) {
        ShoppingCartBean item = getItem(position);

        ImageView imageView=holder.getItemView(R.id.id_confic_img);
        // 显示图片的配置
        DisplayImageOptions options = new DisplayImageOptions.Builder().showImageOnLoading(R.mipmap.img_loading)
                .showImageOnFail(R.mipmap.img_fail).cacheInMemory(true).cacheOnDisk(true)
                .bitmapConfig(Bitmap.Config.RGB_565).build();
        ImageLoader.getInstance().displayImage(item.getImageUrl(), imageView, options);

        TextView name = holder.getItemView(R.id.id_confic_name);//商品名称
        name.setText(item.getShoppingName());
        TextView desc=holder.getItemView(R.id.id_confic_beizhu); //规格
        desc.setText(item.getDesc());
        TextView price=holder.getItemView(R.id.id_confic_price);//单价
        price.setText(item.getPrice());
        TextView count=holder.getItemView(R.id.id_confic_count);//数量
        count.setText("X"+item.getCount());
        TextView yunfei=holder.getItemView(R.id.id_confic_yunfei);//运费
        yunfei.setText("6元");
        TextView zongjia=holder.getItemView(R.id.id_confic_price_sum);//总价
        Double pricenum=Double.parseDouble(item.getPrice())*item.getCount();
        zongjia.setText(pricenum+"元");
        priceNumcallBack.showPrice(pricenum+6+"元");

        TextView type=holder.getItemView(R.id.id_confic_type);//立即送出
        type.setText("立即送出");
    }

    @Override
    protected int getLayoutId() {
        return R.layout.confirmorder_list_item;
    }


}
